#!/usr/bin/perl

use strict;
use Config;
use File::Spec;
use File::Find;
use File::Temp qw(tempfile);

my %seen;


my %local_inc = map {$_, 1} grep {
  $_ ne $Config{installarchlib} &&
  $_ ne $Config{installprivlib} &&
  $_ ne File::Spec->curdir
} @INC;

foreach my $dir (keys %local_inc) {
  find( { wanted => sub {
	    if ($_ ne $dir and $local_inc{$_}) {  # Don't overlap searches
	      $File::Find::prune = 1;
	      return;
	    }
	    return unless s/\.pm$//;
	    my $module = join '::', File::Spec->splitdir
	      ( File::Spec->abs2rel( $_, $dir ) );
	    $seen{$module} = 1;
	  },
	  no_chdir => 1,
	}, $dir );
}

print "$_|" foreach sort keys %seen;


